package com.seecen.HJM.controller;

import com.seecen.HJM.model.dto.FeedbackDTO;
import com.seecen.HJM.model.entity.Feedback;
import com.seecen.HJM.result.DataVo;
import com.seecen.HJM.result.PageResult;
import com.seecen.HJM.service.FeedbackService;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/feedback")
@CacheConfig(cacheNames = "feedbackCache")
//反馈管理
public class FeedbackController {


    @Autowired
    private FeedbackService service;

    //获取反馈列表
    @PostMapping("/getFeedback")
    public DataVo<PageResult<Feedback>> getFeedback(@RequestBody @Valid FeedbackDTO feedbackDTO){
        return service.getFeedback(feedbackDTO);
    }

    //删除反馈
    @DeleteMapping("/deleteFeedback/{id}")
    public DataVo deleteFeedback(@PathVariable("id") Long feedbackId){
        return service.deleteFeedback(feedbackId);
    }

    //批量删除
    @PostMapping("/deleteFeedbackList")
    public DataVo deleteFeedback(@RequestBody List<Long> feedbackIds){
        return service.deleteFeedbackList(feedbackIds);
    }


    //用户提供反馈
    @PostMapping("/addFeedback")
    public DataVo addFeedback(@RequestParam(value = "content") String content){
        return service.addFeedback(content);
    }
}
